package com.chenfan.ccp.plug.log.config;


import com.chenfan.ccp.plug.log.handler.DynamicDataSourceInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 动态数据源的配置
 */
public class DynamicDataSourceConfig implements InitializingBean {
    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Override
    public void afterPropertiesSet() throws Exception {
        sqlSessionFactory.getConfiguration().addInterceptor(new DynamicDataSourceInterceptor());
    }
}
